# from meiduo_mall33.libs.yuntongxun.sms import CCP
# from celery_tasks.main import celery_app
#
# # @celery_app.task(name = 'send_sms' )
# # @celery_app.task()       #加了装饰器的方法才是任务
# @celery_app.task()
# def send_sms(to, datas, tempid):
#     # ccp = CCP()
#     # ccp.send_template_sms(mobile, [sms_code, constants.SMS_CODE_EXPIRES / 60], 1)
#     # print(sms_code)
#     print(datas[0])


from meiduo_mall33.libs.yuntongxun.sms import CCP
from celery_tasks.main import celery_app
import time


@celery_app.task(name='send_sms', bind=True, retry_backoff=3)
def send_sms(self, to, datas, tempid):
    try:
        # time.sleep(5)
        # ccp = CCP()
        # ccp.send_template_sms(mobile, [sms_code, constants.SMS_CODE_EXPIRES / 60], 1)
        print(datas[0])
    except Exception as e:
        # 当失败时，任务重试
        self.retry(exc=e, max_retries=2)

